/**
 * @ClassName LC141
 * @Author ykx
 * @Date 2024/3/22 16:52
 * @Version 1.0
 */
public class LC141 {
    public boolean hasCycle(ListNode head) {
        ListNode fast = head;
        ListNode slow = head;
        while (fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
            if (fast == slow) {
                return true;
            }
        }
        return false;
    }
}
